<div class="row">
  <div id="filter-report" class="col-md-3 col-sm-12 order-md-9 d-none d-md-block mb-3">
    <div class="card">
      <div class="card-header"><i class="fas fa-filter"></i> {{ text_filter }}</div>
      <div class="card-body">
        <div class="form-group">
          <label class="col-form-label" for="input-date-start">{{ entry_date_start }}</label>
          <div class="input-group date">
            <input type="text" name="filter_date_start" value="{{ filter_date_start }}" placeholder="{{ entry_date_start }}" id="input-date-start" class="form-control"/>
            <div class="input-group-append">
              <div class="input-group-text"><i class="fas fa-calendar"></i></div>
            </div>
          </div>
        </div>
        <div class="form-group">
          <label class="col-form-label" for="input-customer">{{ entry_customer }}</label> <input type="text" name="filter_customer" value="{{ filter_customer }}" placeholder="{{ entry_customer }}" id="input-customer" class="form-control"/>
        </div>
        <div class="form-group">
          <label class="col-form-label" for="input-date-end">{{ entry_date_end }}</label>
          <div class="input-group date">
            <input type="text" name="filter_date_end" value="{{ filter_date_end }}" placeholder="{{ entry_date_end }}" id="input-date-end" class="form-control"/>
            <div class="input-group-append">
              <div class="input-group-text"><i class="fas fa-calendar"></i></div>
            </div>
          </div>
        </div>
        <div class="form-group text-right">
          <button type="button" id="button-filter" class="btn btn-light"><i class="fas fa-filter"></i> {{ button_filter }}</button>
        </div>
      </div>
    </div>
  </div>
  <div class="col-md-9 col-sm-12">
    <div class="card">
      <div class="card-header"><i class="fas fa-chart-bar"></i> {{ heading_title }}</div>
      <div class="card-body">
        <div class="table-responsive">
          <table class="table table-bordered">
            <thead>
              <tr>
                <td class="text-left">{{ column_customer }}</td>
                <td class="text-left">{{ column_email }}</td>
                <td class="text-left">{{ column_customer_group }}</td>
                <td class="text-left">{{ column_status }}</td>
                <td class="text-right">{{ column_points }}</td>
                <td class="text-right">{{ column_orders }}</td>
                <td class="text-right">{{ column_total }}</td>
                <td class="text-right">{{ column_action }}</td>
              </tr>
            </thead>
            <tbody>
              {% if customers %}
                {% for customer in customers %}
                  <tr>
                    <td class="text-left">{{ customer.customer }}</td>
                    <td class="text-left">{{ customer.email }}</td>
                    <td class="text-left">{{ customer.customer_group }}</td>
                    <td class="text-left">{{ customer.status }}</td>
                    <td class="text-right">{{ customer.points }}</td>
                    <td class="text-right">{{ customer.orders }}</td>
                    <td class="text-right">{{ customer.total }}</td>
                    <td class="text-right"><a href="{{ customer.edit }}" data-toggle="tooltip" title="{{ button_edit }}" class="btn btn-primary"><i class="fas fa-pencil-alt"></i></a></td>
                  </tr>
                {% endfor %}
              {% else %}
                <tr>
                  <td class="text-center" colspan="8">{{ text_no_results }}</td>
                </tr>
              {% endif %}
            </tbody>
          </table>
        </div>
        <div class="row">
          <div class="col-sm-6 text-left">{{ pagination }}</div>
          <div class="col-sm-6 text-right">{{ results }}</div>
        </div>
      </div>
    </div>
  </div>
</div>
<script type="text/javascript"><!--
$('#button-filter').on('click', function() {
	var url = '';

	var filter_customer = $('input[name=\'filter_customer\']').val();

	if (filter_customer) {
		url += '&filter_customer=' + encodeURIComponent(filter_customer);
	}

	var filter_date_start = $('input[name=\'filter_date_start\']').val();

	if (filter_date_start) {
		url += '&filter_date_start=' + encodeURIComponent(filter_date_start);
	}

	var filter_date_end = $('input[name=\'filter_date_end\']').val();

	if (filter_date_end) {
		url += '&filter_date_end=' + encodeURIComponent(filter_date_end);
	}

	location = 'index.php?route=report/report&code=customer_reward&user_token={{ user_token }}' + url;
});
//--></script>
<script type="text/javascript"><!--
$('.date').datetimepicker({
	'format': 'YYYY-MM-DD',
	'locale': '{{ datepicker }}',
	'allowInputToggle': true
});
//--></script>
<script type="text/javascript"><!--
$('input[name=\'filter_customer\']').autocomplete({
	'source': function(request, response) {
		$.ajax({
			url: 'index.php?route=customer/customer/autocomplete&user_token={{ user_token }}&filter_name=' + encodeURIComponent(request),
			dataType: 'json',
			success: function(json) {
				response($.map(json, function(item) {
					return {
						label: item['name'],
						value: item['customer_id']
					}
				}));
			}
		});
	},
	'select': function(item) {
		$('input[name=\'filter_customer\']').val(item['label']);
	}
});
//--></script>